<html>
<head>
<style>
  .ace_editor {
    border: 0;
    width: auto;
    height: 100%;
    margin: 0;
    top:0;
    right:0;
    bottom:0;
    left:0;
    z-index: 10000;
    touch-action: none;
  }

  body {
    padding: 0px;
    margin: 0px;
    overflow: hidden;
    -ms-overflow-style: scrollbar;
  }
</style>
</head>
<body>
<textarea id="source">package com.sencha.gxt.explorer.client.databinding;

import com.google.gwt.editor.client.Editor;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.core.client.util.Util;
import com.sencha.gxt.examples.resources.client.model.Stock;
import com.sencha.gxt.widget.core.client.button.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer;
import com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer.CssFloatData;
import com.sencha.gxt.widget.core.client.event.SelectEvent.HasSelectHandlers;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FormPanel;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;

public class StockEditor implements IsWidget, Editor<Stock> {

  private FormPanel panel;
  private CssFloatLayoutContainer container;
  private TextButton save;

  TextField name;
  TextField symbol;

  public StockEditor() {
    name = new TextField();
    name.setEnabled(false);
    symbol = new TextField();
    symbol.setEnabled(false);

    save = new TextButton("Save");
    save.setEnabled(false);

    ButtonBar buttons = new ButtonBar();
    BoxLayoutData flex = new BoxLayoutData();
    flex.setFlex(1);
    buttons.add(new LabelToolItem(Util.NBSP_SAFE_HTML), flex);
    buttons.add(save);


    container = new CssFloatLayoutContainer();
    container.add(new FieldLabel(name, "Name"), new CssFloatData(1, new Margins(0, 0, 5, 0)));
    container.add(new FieldLabel(symbol, "Symbol"), new CssFloatData(1, new Margins(0, 0, 5, 0)));
    container.add(buttons, new CssFloatData(1, new Margins(0)));

    panel = new FormPanel();
    panel.setLabelWidth(50);
    panel.setWidget(container);
    panel.setLabelWidth(50);
  }

  @Override
  public Widget asWidget() {
    return panel;
  }

  public void setSaveEnabled(boolean enabled) {
    save.setEnabled(enabled);
    name.setEnabled(enabled);
    symbol.setEnabled(enabled);
    if (!enabled) {

      name.setValue("");
      symbol.setValue("");
    }
  }

  public HasSelectHandlers getSaveButton() {
    return save;
  }

}
</textarea>

<script src="../../samples/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
  var type = "{type}";
  if (type == ("{" + "type}")) {
    // something went wrong, use java as default
    type = "java";
  }
  var editor = ace.edit("source");
  var mode = "ace/mode/" + type;
  var theme = "ace/theme/chrome";
  var readOnly = true;
  editor.getSession().setMode(mode);
  editor.getSession().setUseWorker(false);
  editor.setTheme(theme);
  editor.setShowPrintMargin(false);
  editor.renderer.setShowGutter(true);
  editor.setHighlightActiveLine(false);
  editor.setDisplayIndentGuides(true);
  editor.setReadOnly(readOnly);
  editor.renderer.setPadding(10);
  editor.renderer.setScrollMargin(10, 10, 0, 0);
  editor.getSession().setOptions({
    tabSize: 8,
    useSoftTabs: true,
    useWrapMode: false,
  });
</script>
</body>
</html>